package servlet;

import com.fasterxml.jackson.databind.ObjectMapper;
import entity.Faci;
import service.FaciService;
import service.impl.FaciServiceImpl;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;

/**
 * 更新faci中的数据
 */
@WebServlet("/FacilityUpdateServlet")
public class FacilityUpdateServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request, response);
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //String id=request.getParameter("id");
        String name=request.getParameter("name");
        String contractor=request.getParameter("contractor");
        String phone=request.getParameter("phone");
        String leader=request.getParameter("leader");
        String date=request.getParameter("community");
        System.out.println(date);
        Faci faci=new Faci(null,name,contractor,phone,leader,date);
        FaciService faciService=new FaciServiceImpl();

        PrintWriter printWriter=response.getWriter();
        printWriter.print(new ObjectMapper().writeValueAsString(faciService.saveFaci(faci)));

    }
}
